<template>
  <div class="setup-passwd">
    <span class="up-title">我的密码</span>
    <div class="up-cont">
      <input placeholder="请输入原密码" v-model="oldPassword" type="password" class="up-input">
      <input placeholder="请输入新密码" v-model="newPassword1" type="password" class="up-input">
      <input placeholder="请确认新密码" v-model="newPassword2" type="password" class="up-input">
      <div class="up-btn" @click="updatePassword()">修改</div>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      oldPassword:null,
      newPassword1:null,
      newPassword2:null
    }
  },
  created(){

  },
  methods:{
    updatePassword(){
      if(!this.oldPassword){
        this.$message('请输入原密码');
        return;
      }
      if(!this.newPassword1){
        this.$message('请输入新密码');
        return;
      }
      if(!this.newPassword2){
        this.$message('请确认新密码');
        return;
      }
      let param = {
        oldPassword:this.oldPassword,
        newPassword1:this.newPassword1,
        newPassword2:this.newPassword2
      };
      this.$http.postForm('/user/updatePassword', param, res=>{
        this.$message.success('修改成功');
        this.util.goback();
        // if(history.state){
        //   this.$router.back(-1);
        // }else{
        //   this.$router.push('/');
        // }
      });
    }
  }
}
</script>

<style lang='scss' scoped>
.setup-passwd {
  margin-top: 10px;
  padding: 30px;
  .up-title {
    display: inline-block;
    vertical-align: top;
    //38 + 2
    line-height: 40px;
    text-align: center;
    width: 100px;
    color: #aaaaaa;
  }
  .up-cont {
    display: inline-block;
    width: calc(100% - 100px);
    .up-input {
      margin-bottom: 15px;
      display: block;
      padding: 0 0 0 8px;
      outline: none;
      line-height: 38px;
      width: 300px;
      border: 1px solid #DDDDDD;
      border-radius: 3px;
    }
    .up-btn {
      margin-top: 30px;
      cursor: pointer;
      text-align: center;
      width: 100px;
      line-height: 40px;
      background-color: $base-color;
      color: #ffffff;
      border-radius: 20px;
      font-size: 15px;
    }
  }
}
</style>